<template>
  <div class="nav">
    <h2>UNI-ADMIN</h2>
    <el-menu
      router
      :default-active="active"
      class="el-menu-demo"
      mode="horizontal"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <el-menu-item index="/index">首页</el-menu-item>
      <el-menu-item index="/shop">商品</el-menu-item>
      <el-menu-item index="/order">订单</el-menu-item>
      <el-menu-item index="/vip">会员</el-menu-item>
      <el-menu-item index="/setting">设置</el-menu-item>
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-user-solid"></i>
          <span>{{user}}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="1-1">修改</el-menu-item>
          <el-menu-item index="1-2" @click="loginOut">退出</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      active: "/index",
      user: "",
    };
  },
  methods: {
    loginOut() {
      localStorage.removeItem("user");
      this.$router.push("/login");
      this.$message("退出成功");
    },
  },
  created() {
    this.user = localStorage.getItem("user");
  },
  mounted() {},
  components: {},
  watch: {},
};
</script>

<style scoped>
.nav {
  display: flex;
  background-color: #545c64;
}
h2 {
  width: 20%;
  line-height: 60px;
  font-size: 28px;
  color: white;
}
>>> .el-menu-demo {
  padding-left: 40%;
}
</style>